<template>
  <div class="app-container">
    <el-form :model="searchForm" :inline="true">
      <el-row>
        <el-col :span="18">
          <el-form-item prop="fuzzy">
            <el-input
              v-model="searchForm.fuzzy"
              style="width: 250px"
              placeholder="试剂试剂名称/编号"
            />
          </el-form-item>
          <el-form-item prop="norms" label="试剂规格:">
            <el-select
              v-model="searchForm.norms"
              style="width: 145px"
              placeholder="请选择试剂规格"
              clearable
            >
              <el-option
                v-for="item in norms"
                :key="item.id"
                :label="item.name"
                :value="item.name"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="state" label="试剂状态:">
            <el-select
              v-model="searchForm.state"
              style="width: 145px"
              placeholder="请选择试剂状态"
              clearable
            >
              <el-option
                v-for="item in state"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item>
            <template>
              <el-button
                type="primary"
                class="iconfont icon-chaxun1"
                size="small"
                @click="handleSearch"
              >
                查询</el-button
              >
              <el-button type="primary" size="small" @click="tabPrint">
                标签打印</el-button
              >
              <el-button type="primary" size="small" @click="InstrumentData">
                批量报废</el-button
              >
              <el-button type="primary" size="small" @click="earlyData">
                批量降级</el-button
              >
              <template v-if="showTitle">
                <el-row
                  style="text-align: center; font-size: 14px; margin-top: 10px"
                >
                  <el-col :span="24"
                    >Web打印服务C-Lodop软件未安装启动，请<a
                      href="#"
                      style="color: red"
                      @click="fileDownLoad"
                      >点击这里</a
                    >下载执行安装</el-col
                  >
                </el-row>
                <!--              <el-row style="text-align:center;font-size:14px;padding-top:3px;">-->
                <!--                <el-col :span="24">(若此前已安装过，<a href="#" style="color:red" @click="tabPrint">可点这里直接再次启动</a>），成功后请刷新本页面。</el-col>-->
                <!--              </el-row>-->
              </template>
              <template v-else>
                <div style="visibility: hidden">信息提示</div>
              </template>
            </template>
          </el-form-item>
        </el-col>
        <el-col :span="6" class="search-right">
          <el-button type="text" @click="handleCreate">新增</el-button>
          <el-button type="text" @click="handleUpload">导入</el-button>
          <el-button type="text" @click="handleDownload">导出</el-button>
        </el-col>
      </el-row>
    </el-form>

    <el-dialog
      title="批量导入"
      :visible.sync="uploadVisible"
      append-to-body
      width="53%"
    >
      <div class="block">
        <el-timeline>
          <el-timeline-item size="large">
            <span slot="dot" class="time-dot"> 1 </span>
            <el-row>
              <el-col :span="24"> 下载模板，批量填写信息 </el-col>
            </el-row>
            <el-row style="padding-top: 10px">
              <el-col :span="24">
                <el-button
                  size="mini"
                  type="primary"
                  @click="handleDownloadData()"
                  >模板下载</el-button
                >
              </el-col>
            </el-row>
          </el-timeline-item>
          <el-timeline-item size="large">
            <span slot="dot" class="time-dot"> 2 </span>
            <el-row>
              <el-col :span="24"> 上传填写好的信息表格 </el-col>
            </el-row>
            <el-row style="padding-top: 10px">
              <el-col :span="24">
                <el-upload
                  class="upload-demo"
                  action="/api/excel/importReagent"
                  :on-change="customUploadChange"
                  :file-list="excelFileList"
                  :limit="1"
                  style="width: 300px"
                >
                  <el-button size="mini" type="primary">点击上传</el-button>
                  <!-- <div class="el-upload__text"><em>点击上传</em></div> -->
                </el-upload>
              </el-col>
            </el-row>
          </el-timeline-item>
        </el-timeline>
        <el-row>
          <el-col :span="24" style="">
            <span style="color: red; font-size: 13px"
              >备注：批量导入功能，请上传正确格式 否则不展示在列表。</span
            >
          </el-col>
        </el-row>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="uploadVisible = false">关闭</el-button>
      </div>
    </el-dialog>

    <div>
      <el-table
        ref="stockTable"
        stripe
        border
        :data="factorData"
        class="table-item"
        highlight-current-row
        :header-cell-style="{ background: '#ECF3FC' }"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <template slot="empty">
          <div class="table_empty">
            <div class="empty_tips">
              <span> 暂无数据 </span>
            </div>
          </div>
        </template>
        <el-table-column
          type="selection"
          fixed="left"
          width="55"
          align="center"
        />
        <el-table-column type="index" width="70" align="center" label="序号" />
        <el-table-column
          prop="code"
          label="试剂编号"
          width="180"
          align="center"
        />
        <el-table-column
          prop="name"
          label="试剂名称"
          width="180"
          align="center"
        />
        <el-table-column prop="model" label="型号" width="110px" align="center">
        </el-table-column>
        <el-table-column prop="norms" label="规格" width="130px" align="center">
        </el-table-column>
        <el-table-column prop="batch" label="批号" width="130" align="center" />
        <el-table-column
          prop="date"
          label="生产日期"
          width="180"
          align="center"
        />
        <el-table-column
          prop="validity"
          label="有效期"
          width="120"
          align="center"
        >
          <template slot-scope="scope">
            <span> {{ scope.row.validity }} {{ "个月" }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="expireDate"
          label="失效日期"
          width="100px"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="day"
          label="过期倒计时"
          width="140"
          align="center"
        >
        <template slot-scope="scope">
            <span :class="scope.row.day > 0 ? 'green' : 'red'">
              {{ scope.row.day }}{{"天"}}</span
            >
          </template>
        </el-table-column>
        <el-table-column
          prop="singleSize"
          label="基本重量/体积/数量"
          width="180"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="size"
          label="小包装数量"
          width="180"
          align="center"
        />

        <el-table-column
          prop="bigSize"
          label="大包装数量"
          width="100"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="total"
          label="总数量"
          width="180"
          align="center"
        />
        <el-table-column
          prop="surplus"
          label="剩余数量"
          width="150"
          align="center"
        >
        </el-table-column>

        <el-table-column
          prop="state"
          label="试剂状态"
          width="180"
          align="center"
        >
          <template slot-scope="scope">
            <span
              v-if="scope.row.state == 1"
              style="background: #81c784;padding: 20px;color: #fff;;"
              >待入库</span
            >
            <span
              v-if="scope.row.state == 2"
              style="background: #13CE66;padding: 20px;color: #fff;;"
              >有效</span
            >
            <span
              v-if="scope.row.state == 3"
              style="background: #E3C000;padding: 20px;color: #fff;;"
              >降级</span
            >
            <span
              v-if="scope.row.state == 4"
              style="background: #ff1100;padding: 20px;color: #fff;;"
              >失效</span
            >
            <span
              v-if="scope.row.state == 5"
              style="background: #c9b9b9;padding: 20px;color: #fff;;"
              >已用完</span
            >
            <span
              v-if="scope.row.state == 6"
              style="background: #607d8b;padding: 20px;color: #fff;;"
              >报废</span
            >
          </template>
        </el-table-column>

        <el-table-column fixed="right" align="center" label="操作" width="180">
          <template slot-scope="scope">
            <el-button type="text" @click="View(scope.row)"> 查看</el-button>
            <div class="erc-divider-vertical" v-if="scope.row.state != 2" />
            <el-button
              type="text"
              v-if="scope.row.state != 2"
              @click="edit(scope.row)"
              >编辑</el-button
            >
            <div class="erc-divider-vertical" />
            <el-dropdown>
              <span class="el-dropdown-link"> 更多 </span>
              <el-dropdown-menu>
                <el-dropdown-item
                  ><el-button type="text" @click="handleSingle(scope.row)"
                    >单品标签打印</el-button
                  ></el-dropdown-item
                >
                <el-dropdown-item>
                  <el-button type="text" @click="earlyWarning(scope.row)"
                    >降级</el-button
                  ></el-dropdown-item
                >
                <el-dropdown-item>
                  <el-button type="text" @click="Instrument(scope.row)"
                    >报废</el-button
                  ></el-dropdown-item
                >
                <el-dropdown-item
                  ><el-button
                    type="text"
                    v-if="scope.row.state == 2"
                    @click="handleCopy(scope.row)"
                    >复制</el-button
                  ></el-dropdown-item
                >
                <el-dropdown-item
                  ><el-button type="text" @click="handleDelete(scope.row)"
                    >删除</el-button
                  ></el-dropdown-item
                >
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div style="">
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="searchForm.pageNumber"
        :limit.sync="searchForm.pageSize"
        @pagination="handleSearch"
      />
    </div>

    <!-- 新增/编辑弹框 -->
    <el-dialog
      :title="titleMap[orderDialogStatus]"
      :visible.sync="orderDialogVisible"
      center
      :tree-props="{ children: 'childList', hasChildren: 'hasChildren' }"
    >
      <el-form ref="orderForm" :model="orderForm" :rules="rules">
        <el-card shadow="never">
          <div slot="header">
            <span>试剂试剂基础信息<i class="el-input__icon"/></span>
          </div>

          <el-row>
            <el-col :span="8">
              <el-form-item prop="name" label="试剂名称:" label-width="100px">
                <el-select
                  value-key="id"
                  v-model="orderForm.name"
                  clearable
                  style="width: 100%"
                  @change="smallListNameClick"
                >
                  <el-option
                    v-for="item in smallListName"
                    :key="item.id"
                    :label="item.name"
                    :value="item"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item prop="norms" label="规格:" label-width="100px">
                <el-select
                  v-model="orderForm.norms"
                  style="width: 100%"
                  placeholder="请选择"
                >
                  <el-option
                    v-for="item in norms"
                    :key="item.id"
                    :label="item.name"
                    :value="item.name"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="batch" label="批号:" label-width="100px">
                <el-input v-model="orderForm.batch" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">
              <el-form-item prop="date" label="生产日期:" label-width="100px">
                <el-date-picker
                  v-model="orderForm.date"
                  style="width: 100%"
                  value-format="yyyy-MM-dd"
                  type="date"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="validity" label="有效期:" label-width="100px">
                <el-input @input="handleEdit" v-model="orderForm.validity"
                  ><i
                    slot="suffix"
                    style="font-style:normal;margin-right: 10px;"
                    >个月</i
                  ></el-input
                >
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">
              <el-form-item
                prop="singleUnit"
                label="基本计量单位:"
                label-width="120px"
              >
                <el-select
                  v-model="orderForm.singleUnit"
                  clearable
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in measureList"
                    :key="item.id"
                    :label="item.unit"
                    :value="item.unit"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="singleSize"
                label="基本重量/体积/数量:"
                label-width="150px"
              >
                <el-input v-model="orderForm.singleSize" @input="changeA" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">
              <el-form-item prop="unit" label="小包装单位:" label-width="100px">
                <el-select
                  value-key="id"
                  v-model="orderForm.unit"
                  clearable
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in smallList"
                    :key="item.id"
                    :label="item.unit"
                    :value="item.unit"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="size" label="小包装数量:" label-width="100px">
                <el-input v-model="orderForm.size" @input="changeB" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">
              <el-form-item
                prop="bigUnit"
                label="大包装单位:"
                label-width="100px"
              >
                <el-select
                  value-key="id"
                  v-model="orderForm.bigUnit"
                  clearable
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in bigList"
                    :key="item.id"
                    :label="item.unit"
                    :value="item.unit"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="bigSize"
                label="大包装数量:"
                label-width="100px"
              >
                <el-input v-model="orderForm.bigSize" @input="changeC" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="total"
                label="总重量/体积/数量:"
                label-width="150px"
              >
                {{ this.orderForm.total }}
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">
              <el-form-item
                prop="price"
                label="采购单价(元):"
                label-width="110px"
              >
                <el-input v-model="orderForm.price" @input="changeD" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="totalPrice"
                label="总价(元):"
                label-width="100px"
              >
                {{ this.orderForm.totalPrice }}
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <el-card shadow="never">
          <div slot="header">
            <span>试剂试剂剂供应商信息<i class="el-input__icon"/></span>
          </div>
          <el-row>
            <el-col :span="8">
              <el-form-item
                prop="supplier"
                label="供应商名称:"
                label-width="100px"
              >
                <el-input v-model="orderForm.supplier" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="supplierUser"
                label="供应商联系人:"
                label-width="110px"
              >
                <el-input v-model="orderForm.supplierUser" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="supplierPhone"
                label="供应商联系方式:"
                label-width="140px"
              >
                <el-input v-model="orderForm.supplierPhone" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">
              <el-form-item
                prop="manufacturer"
                label="生产厂家:"
                label-width="100px"
              >
                <el-input v-model="orderForm.manufacturer" />
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item
                prop="certificate"
                label="试剂证书:"
                label-width="100px"
              >
                <el-upload
                  ref="waterImage"
                  class="upload-demo"
                  action="/api/reagent/fileUpload"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :before-remove="beforeRemove"
                  :on-change="customUploadChangeImage1"
                  :before-upload="beforeUpload"
                  accept=".jpg,.png,.pdf,.jpeg"
                  name="file"
                  multiple
                  :limit="1"
                  :on-exceed="handleExceedImage1"
                  :file-list="fileList"
                  @click="uploadFiles"
                >
                  <el-button size="small" type="primary" icon="el-icon-upload2"
                    >点击上传</el-button
                  >
                  <!-- <div slot="tip" class="el-upload__tip" style="color:red;">
                      （注：文件大小：小于50MB,文件格式:doc,docx,pdf）
                    </div> -->
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <el-card shadow="never">
          <div slot="header">
            <span>试剂试剂入库验收信息<i class="el-input__icon"/></span>
          </div>
          <el-row>
            <el-col :span="8">
              <el-form-item
                prop="accompany"
                label="陪同人:"
                label-width="120px"
              >
                <el-select
                  v-model="accompany"
                  placeholder="请选择"
                  filterable
                  multiple
                  value-key="userId"
                  style="width:100%"
                  @change="handleAccompanyId"
                >
                  <el-option
                    v-for="item in usernameOptions"
                    :key="item.userId"
                    :label="item.empName"
                    :value="item"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item
                prop="custodiana"
                label="保管人:"
                label-width="110px"
                clearable
              >
                <el-select
                  v-model="custodiana"
                  placeholder="请选择"
                  filterable
                  value-key="userId"
                  @change="handleCustodianId"
                  style="width:100%"
                >
                  <el-option
                    v-for="item in usernameOptions"
                    :key="item.userId"
                    :label="item.empName"
                    :value="item"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item prop="standard" label="标准值:" label-width="140px">
                <el-input v-model="orderForm.standard" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">
              <el-form-item
                prop="uncertainty"
                label="相对不确定度:"
                label-width="120px"
              >
                <el-input v-model="orderForm.uncertainty" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="roomId"
                label="试剂存放位置:"
                label-width="120px"
              >
                <treeselect
                  style="width: 100%"
                  v-model="orderForm.roomId"
                  :options="deptOptions"
                  :normalizer="normalizer"
                  placeholder="选择存放地点"
                  @select="changeId"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="acceptanceType"
                label="验收方式:"
                label-width="140px"
              >
                <el-input v-model="orderForm.acceptanceType" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="16">
              <el-form-item
                prop="conclusion"
                label="验收结论:"
                label-width="110px"
              >
                <el-input type="textarea" v-model="orderForm.conclusion" />
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item
                prop="isCheck"
                label="是否需要期间核查:"
                label-width="140px"
              >
                <el-radio-group v-model="orderForm.isCheck">
                  <el-radio :label="1">需要</el-radio>
                  <el-radio :label="2">不需要</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="orderDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="confirmCreate">确认</el-button>
      </div>
    </el-dialog>
    <!-- 查看弹框 -->
    <el-dialog
      title="试剂试剂详情"
      :visible.sync="orderDialogView"
      center
      width="1400px"
    >
      <el-form ref="orderView" :model="orderView">
        <el-card shadow="never">
          <div slot="header">
            <span>试剂试剂剂基础信息<i class="el-input__icon"/></span>
          </div>

          <el-row>
            <el-col :span="8">
              <el-form-item prop="name" label="试剂名称:" label-width="100px">
                {{ this.orderView.name }}
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="model" label="型号:" label-width="100px">
                {{ this.orderView.model }}
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="norms" label="规格:" label-width="100px">
                {{ this.orderView.norms }}
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">
              <el-form-item prop="batch" label="批号:" label-width="100px">
                {{ this.orderView.batch }}
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="date" label="生产日期:" label-width="100px">
                {{ this.orderView.date }}
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="validity" label="有效期:" label-width="100px">
                {{ this.orderView.validity }}
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">
              <el-form-item
                prop="singleUnit"
                label="基本计量单位:"
                label-width="120px"
              >
                {{ this.orderView.singleUnit }}
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="singleSize"
                label="基本重量/体积/数量:"
                label-width="150px"
              >
                {{ this.orderView.singleSize }}
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">
              <el-form-item prop="unit" label="小包装单位:" label-width="100px">
                {{ this.orderView.unit }}
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="size" label="小包装数量:" label-width="100px">
                {{ this.orderView.size }}
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">
              <el-form-item
                prop="bigUnit"
                label="大包装单位:"
                label-width="100px"
              >
                {{ this.orderView.bigUnit }}
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="bigSize"
                label="大包装数量:"
                label-width="100px"
              >
                {{ this.orderView.bigSize }}
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="total"
                label="总重量/体积/数量:"
                label-width="150px"
              >
                {{ this.orderView.total }}
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">
              <el-form-item
                prop="price"
                label="采购单价(元):"
                label-width="110px"
              >
                {{ this.orderView.price }}
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="totalPrice"
                label="总价(元):"
                label-width="100px"
              >
                {{ this.orderView.totalPrice }}
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <el-card shadow="never">
          <div slot="header">
            <span>试剂试剂单品重量/体积信息<i class="el-input__icon"/></span>
          </div>
          <el-row>
            <el-col
              :span="8"
              v-for="item in this.orderView.bigSubVos"
              :key="item.code"
            >
              <el-form-item
                prop="supplierPhone"
                :label="item.code"
                label-width="150px"
              >
                <div style="display: flex;">
                  <el-progress
                    style="width: 175px;top: 10px;"
                    :text-inside="true"
                    :stroke-width="15"
                    :stroke-height="15"
                    :percentage="item.surplus"
                    status="success"
                    color="#0C77FF"
                  ></el-progress>
                  <P style="margin-top: 0px;"
                    >(剩余{{ item.surplus }}{{ item.unit }})</P
                  >
                </div>
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <el-card shadow="never">
          <div slot="header">
            <span>试剂试剂验收信息<i class="el-input__icon"/></span>
          </div>
          <el-row>
            <el-col :span="8">
              <el-form-item prop="supplier" label="验收人:" label-width="120px">
                {{ this.orderView.reagentStorage.acceptance }}
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="supplierUser"
                label="所属部门:"
                label-width="120px"
              >
                {{ this.orderView.reagentStorage.acDepartment }}
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="supplierPhone"
                label="验收日期:"
                label-width="120px"
              >
                {{ this.orderView.reagentStorage.date }}
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">
              <el-form-item
                prop="manufacturer"
                label="验收方式:"
                label-width="120px"
              >
                {{ this.orderView.reagentStorage.acceptanceType }}
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item
                prop="certificate"
                label="验收结论:"
                label-width="120px"
              >
                {{ this.orderView.reagentStorage.conclusion }}
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <el-card shadow="never">
          <div slot="header">
            <span>试剂试剂入库信息<i class="el-input__icon"/></span>
          </div>
          <el-row>
            <el-col :span="8">
              <el-form-item prop="supplier" label="陪同人:" label-width="120px">
                {{ this.orderView.reagentStorage.accompany }}
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="supplierUser"
                label="入库日期:"
                label-width="120px"
              >
                {{ this.orderView.reagentStorage.date }}
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="supplierPhone"
                label="试剂试剂位置:"
                label-width="120px"
              >
                {{ this.orderView.reagentStorage.room }}
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="8">
              <el-form-item
                prop="manufacturer"
                label="不确定度:"
                label-width="120px"
              >
                {{ this.orderView.reagentStorage.uncertainty }}
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                prop="certificate"
                label="保管人:"
                label-width="120px"
              >
                {{ this.orderView.reagentStorage.custodian }}
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item
                prop="certificate"
                label="保管部门:"
                label-width="120px"
              >
                {{ this.orderView.reagentStorage.department }}
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="orderDialogView = false">取消</el-button>
      </div>
    </el-dialog>
    <!-- 单品标签打印 -->
    <el-dialog
      title="单品标签打印"
      :visible.sync="orderDialogSingle"
      center
      width="700px"
    >
      <el-form ref="orderSingle" :model="orderSingle">
        <el-card shadow="never">
          <div slot="header">
            <span>试剂试剂单品重量/体积信息<i class="el-input__icon"/></span>
          </div>
          <el-row>
            <el-col :span="10">
              <el-form-item prop="ids" label-width="80px">
                <el-tree
                  :data="orderSingle.bigSubVos"
                  :props="defaultProps"
                  @check="currentChecked"
                  show-checkbox
                  node-key="id"
                  style="width:540px"
                >
                  <div
                    style="width:100%;"
                    slot-scope="{ node, data }"
                    @click="showAlert(data, $event)"
                  >
                    <span>
                      <div style="display: flex;">
                        <span style="margin-top: 14px;">{{ node.label }} </span>
                        <el-progress
                          style="width: 175px;height: 16px;top: 24px;left: 5px;"
                          :text-inside="true"
                          :stroke-width="15"
                          :stroke-height="15"
                          :percentage="node.data.surplus"
                          status="success"
                          color="#0C77FF"
                        ></el-progress>
                        <P style="margin-left: 10px;"
                          >(剩余&nbsp;{{ node.data.surplus }}&nbsp;{{
                            node.data.unit
                          }})</P
                        >
                      </div>
                    </span>
                  </div>
                </el-tree>
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="orderDialogSingle = false">取消</el-button>
        <el-button type="primary">确认</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="试剂试剂报废处理"
      :visible.sync="purchaseVisible"
      center
      top="5vh"
      width="40%"
    >
      <el-form :model="claim" :rules="rules" ref="claim" label-width="150px">
        <el-card shadow="never">
          <div slot="header">
            <span>试剂报废处理<i class="el-input__icon"/></span>
          </div>
          <el-form-item label="试剂报废日期:" prop="createTime">
            <el-date-picker
              v-model="claim.createTime"
              style="width: 70%"
              value-format="yyyy-MM-dd"
              type="date"
            />
          </el-form-item>
          <el-form-item label="处理人:" prop="user">
            <el-select
              v-model="accompanyId"
              placeholder="请选择"
              filterable
              multiple
              value-key="userId"
              style="width: 70%"
              @change="handleCheckedCitiesUser"
            >
              <el-option
                v-for="item in usernameOptions"
                :key="item.userId"
                :label="item.empName"
                :value="item"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="负责人:" prop="charge">
            <el-select
              v-model="custodianId"
              placeholder="请选择"
              filterable
              multiple
              value-key="userId"
              @change="handleChecked"
              style="width:70%"
            >
              <el-option
                v-for="item in usernameOptions"
                :key="item.userId"
                :label="item.empName"
                :value="item"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="现场照片:" prop="img">
            <el-upload
              action="/api/reagent/fileUpload"
              list-type="picture-card"
              :on-preview="handlePictureCardPreview"
              :on-success="imgSuccess"
              :on-error="imgError"
              :limit="3"
              :on-exceed="handleExceed"
              :on-change="handleChangeUpload"
              :before-remove="beforeRemove"
            >
              <el-button size="small" type="picture-card">点击上传</el-button>
              <p
                slot="tip"
                class="el-upload__tip"
                style="color: red;margin: -35px 0px -5px 94px;"
              >
                注：(您最多只能上传3张图片，且不超过2M)
              </p>
            </el-upload>
          </el-form-item>

          <el-form-item label="报废原因及说明:" prop="reason">
            <el-input
              type="textarea"
              v-model="claim.reason"
              style="width: 70%"
            ></el-input>
          </el-form-item>
          <el-form-item label="处理方法:" prop="type">
            <el-input
              type="textarea"
              v-model="claim.type"
              style="width: 70%"
            ></el-input>
          </el-form-item>
        </el-card>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="purchaseVisible = false">取消</el-button>
        <el-button type="primary" @click="confirmType">确认</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="降级处理"
      :visible.sync="purchase"
      center
      top="5vh"
      width="20%"
    >
      <el-form :model="claim" :rules="rules" ref="claim" label-width="150px">
        <div style="margin-left: 50px;">该试剂试剂将被降级处理，</div>
        <div style="margin-left: 100px;">是否继续？</div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="purchase = false">取消</el-button>
        <el-button type="primary" @click="earlyWarningData">确认</el-button>
      </div>
    </el-dialog>

    <!-- 现场照片预览 -->
    <el-dialog :visible.sync="dialogVisible" center top="5vh" width="50%">
      <el-form :model="claim" :rules="rules" ref="claim" label-width="150px">
        <img :src="this.dialogImageUrl" alt="" style="width: 100%;" />
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import * as List from "@/api/List";
import { getUser } from "@/api/system/user";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import * as reagentsGlance from "@/api/reagentsGlance";
import { getLodop } from "@/utils/LodopFuncs";
import Pagination from "@/components/Pagination"; // Secondary package based on el-pagination

export default {
  components: {
    Pagination,
    getLodop,
    getUser,
    Treeselect
  },
  data() {
    return {
      // 部门树选项
      deptOptions: [],
      isPreview: false,
      dialogVisible: false,
      file: "",
      searchForm: {
        pageNumber: 1,
        pageSize: 10,
        type: 2,
        state: ""
      },
      searData: {
        pageNumber: 1,
        pageSize: 10,
        type: 2
      },
      factorData: [],
      total: 0,
      selection: [],
      multiplese: [],
      printList: [],
      showTitle: false,
      orderDialogStatus: "create",
      orderDialogVisible: false,
      orderDialogView: false,
      orderDialogSingle: false,
      purchaseVisible: false,
      titleMap: {
        edit: "修改标准物质",
        create: "新增标准物质"
      },

      //新增数据
      orderForm: {
        id: "",
        type: 2,
        batch: "",
        bigSize: "",
        bigUnit: "",
        date: "",
        manufacturer: "",
        model: "",
        name: "",
        norms: "",
        price: "",
        singleSize: "",
        singleUnit: "",
        size: "",
        supplier: "",
        supplierPhone: "",
        supplierUser: "",
        unit: "",
        validity: "",
        totalPrice: "",
        total: "",
        certificate: "",
        isCheck: 1
      },
      orderForm1: {
        id: "",
        type: 2,
        batch: "",
        bigSize: "",
        bigUnit: "",
        date: "",
        manufacturer: "",
        model: "",
        name: "",
        norms: "",
        price: "",
        singleSize: "",
        singleUnit: "",
        size: "",
        supplier: "",
        supplierPhone: "",
        supplierUser: "",
        unit: "",
        validity: "",
        totalPrice: "",
        total: "",
        certificate: "",
        isCheck: 1
      },
      defaultProps: {
        children: "reagentSubs",
        label: "code"
      },
      smallListName: {},
      orderView: {
        reagentStorage: [],
        bigSubVos: {}
      },
      orderSingle: {
        bigSubVos: []
      },
      claim: {
        ids: [],
        img: "",
        createTime: ""
      },
      purchase: false,
      dialogImageUrl: "",
      accompany: [],
      custodiana: [],
      accompanyId: [],
      custodianId: [],
      usernameOptions: [],
      img: [],
      id: "",
      totalVos: "",
      fileList: [],
      measureList: {},
      smallList: {},
      bigList: {},
      uploadVisible: false,
      fileResult: "",
      excelFileList: [],
      norms: [
        {
          name: "基准试剂(PT)",
          id: 1
        },
        {
          name: "优级纯(GR)",
          id: 2
        },
        {
          name: "分析纯(AR)",
          id: 3
        },
        {
          name: "化学纯(CP)",
          id: 4
        }
      ],
      state: [
        {
          name: "待入库",
          id: 1
        },
        {
          name: "有效",
          id: 2
        },
        {
          name: "降級",
          id: 3
        },
        {
          name: "失效",
          id: 4
        },
        {
          name: "已用完",
          id: 5
        },
        {
          name: "报废",
          id: 6
        }
      ],
      // 表单校验
      rules: {
        name: [
          { required: true, message: "试剂名称不能为空", trigger: "blur" }
        ],
        model: [{ required: true, message: "型号不能为空", trigger: "blur" }],
        norms: [{ required: true, message: "规格不能为空", trigger: "blur" }],
        date: [
          { required: true, message: "生产日期不能为空", trigger: "blur" }
        ],
        validity: [
          { required: true, message: "有效期不能为空", trigger: "blur" }
        ],
        singleUnit: [
          { required: true, message: "基本计量单位不能为空", trigger: "blur" }
        ],
        singleSize: [
          {
            required: true,
            message: "基本重量/体积/数量不能为空",
            trigger: "blur"
          }
        ],
        price: [
          { required: true, message: "采购单价(元)不能为空", trigger: "blur" }
        ],
        roomId: [
          { required: true, message: "存放地点不能为空", trigger: "blur" }
        ],
        conclusion: [
          { required: true, message: "验收结论不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.handleSearch();
  },
  methods: {
    handleSearch() {
      reagentsGlance.reagentList(this.searchForm).then(res => {
        console.log(res);
        if (res.code === 200) {
          this.factorData = res.result.records || [];
          this.total = res.result.total;
          console.log(this.total);
          console.log(this.factorData);
        }
      });
    },
    // 在 Input 值改变时触发
    handleEdit(e) {
      let value = e.replace(/^(0+)|[^\d]+/g, ""); // 以0开头或者输入非数字，会被替换成空
      this.orderForm.validity = value;
    },
    // 获取列表勾中id
    handleSelectionChange(val) {
      console.log(val);
      this.multiplese = val;
      var arr = [];
      var selectAll = [];
      for (var item of val) {
        selectAll.push(item);
        this.tableData1 = selectAll;
        arr.push(item.id);
        // console.log(item.id);
        this.Selection = arr;
        console.log(this.Selection);
      }
    },

    // 标签打印
    tabPrint() {
      if (this.multiplese && this.multiplese.length > 0) {
        this.printList = this.multiplese;
        console.log(this.printList);
        this.$nextTick(() => {
          this.tagPrint();
          // this.qrcode();
        });
      } else {
        this.$message.info("最少选择一条记录信息");
      }
    },
    tagPrint() {
      const LODOP = getLodop();
      for (let student of this.printList) {
        let printStr = `<div style="text-align: center;padding-top: 10px;font-size:22px;font-weight:bold;font-family: SimHei;">${
          student.name
        }</div>
          <div style="float:right;
                      width: 120%;
                      height: 0.5px;
                      margin-top: 10px;
                      background:#0a0a0a;
                      position: relative;
                      text-align: center;"></div>
					<div style="padding-left: 97px;font-size:12px;padding-top:9px;display: flex">编号: <div style="font-size:10px;padding-top: 1px">${
            student.code
          }</div>
          </div>
                <div style="padding-left: 97px;font-size:12px;padding-top:8px;display: flex">重量/体积: ${student.remainTotal +
                  student.singleUnit}</div>
					<div style="padding-left: 97px;font-size:12px;padding-top:8px;display: flex"">规格: ${
            student.norms
          }</div>
					<div style="padding-left: 97px;font-size:12px;padding-top:8px;display: flex"">失效日期: ${
            student.expireDate
          }</div>
          `;
        LODOP.NewPage(); //创建新的页，实现多页打印
        //因为对边缘没啥要求，直接根据内容来居中
        LODOP.ADD_PRINT_HTM(0, 0, "60mm", "40mm", printStr);
        LODOP.ADD_PRINT_BARCODE(52, 5, 100, 100, "QRCode", "" + student.id);
      }
      LODOP.SET_PRINT_MODE("TRYLINKPRINTER_NOALERT", true); // 这个语句设置网络共享打印机连接不通时是否提示一下
      LODOP.PREVIEW();
    },
    //C-Lodop软件下载
    fileDownLoad() {
      var url =
        this.$store.getters.sysBaseUrl +
        "/downLoad/CLodop_Setup_for_Win64NT_4.159EN.exe";
      window.open(url);
    },
    // 导入模板
    customUploadChange(file) {
      if (file.status === "ready") return;
      if (file.status === "success") {
        const res = file.response || {};
        if (res && res.code === 200) {
          this.fileResult = file.response.result;
          console.log(this.fileResult);
          this.$message({
            type: "success",
            message: file.response.message
          });
          this.handleSearch();
          this.uploadVisible = false;
        } else {
          this.$message.error("上传失败!");
          this.excelFileList = [];
        }
      } else {
        this.$message.error("上传失败!");
        this.excelFileList = [];
      }
    },
    /** 下载模板 */
    handleDownloadData() {
      var url = "/api/excel/exportReagentTp";
      window.open(url);
    },
    /** 导出按钮操作 */
    handleDownload() {
      var url =
        "/api/excel/exportReagent?type=" +
          2 +
          "&state=" +
          this.searchForm.state ||
        "" + "&norms=" + this.searchForm.norms ||
        "" + "&fuzzy=" + this.searchForm.fuzzy ||
        "";
      window.open(url);
    },
    handleUpload() {
      this.uploadVisible = true;
      this.excelFileList = [];
      this.fileResult = "";
    },
    // 新增
    handleCreate() {
      this.orderForm = {
        id: "",
        type: 2,
        batch: "",
        bigSize: "",
        bigUnit: "",
        date: "",
        manufacturer: "",
        model: "",
        name: "",
        norms: "",
        price: "",
        singleSize: "",
        singleUnit: "",
        size: "",
        supplier: "",
        supplierPhone: "",
        supplierUser: "",
        unit: "",
        validity: "",
        totalPrice: "",
        total: "",
        isCheck: 1
      };
      this.accompany = "";
      this.custodiana = "";
      this.orderDialogStatus = "create";
      this.orderDialogVisible = true;
      reagentsGlance.unitDropDown().then(res => {
        console.log(res);
        this.measureList = res.result.measureList || [];
        this.smallList = res.result.smallList || [];
        this.bigList = res.result.bigList || [];
      });
      this.smallListData();
    },
    /** 转换部门数据结构 */
    normalizer(node) {
      if (node.childList && !node.childList.length) {
        delete node.childList;
      }
      return {
        id: node.id,
        label: node.name,
        children: node.childList
      };
    },
    changeId(e) {
      console.log(e);
      this.orderForm.roomId = e.id;
      this.orderForm.room = e.name;
    },
    //编辑
    edit(row) {
      this.orderDialogVisible = true;
      this.orderDialogStatus = "edit";
      reagentsGlance.detail({ id: row.id }).then(res => {
        console.log(res);
        this.orderForm = res.result;
      });
      this.smallListData();
    },
    //试剂名称下拉
    smallListData() {
      reagentsGlance.nameList(this.searData).then(res => {
        console.log(res);
        this.smallListName = res.result.records;
      });
      //领取人
      List.userList().then(res => {
        this.usernameOptions = res.result;
      });
      //存放位置
      List.roomList().then(res => {
        this.deptOptions = res.result;
      });
    },
    //查看
    View(row) {
      this.orderDialogView = true;
      reagentsGlance.detail({ id: row.id }).then(res => {
        console.log(res);
        this.orderView = res.result;
        console.log(this.orderView);
      });
    },
    // 文件上传
    beforeUpload(e) {
      // console.log(e);
      this.file = e;
    },
    uploadFiles(e) {
      // console.log(e.target.file);
    },
    handleRemove(file, fileList) {
      // console.log(file, fileList);
    },
    handlePreview(file) {
      // console.log(file);
    },
    handleExceedImage1(file, fileList) {
      // console.log(file);
      this.$message.warning(
        `当前限制选择 1 张图片，以选 ${file.length} 张照片`
      );
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    //上传文件1
    customUploadChangeImage1(file) {
      console.log(file);
      if (file.status === "ready") return;
      if (file.status === "success") {
        const res = file.response || {};
        if (res && res.code === 200) {
          this.fileResult = file.response.result.split("/");
          this.orderForm.certificate = this.fileResult[2];
          console.log(this.fileResult);
          this.$message({
            type: "success",
            message: "上传成功!"
          });
        } else {
          this.$message.error("上传失败!");
          this.fileList = [];
        }
      } else {
        this.$message.error("上传失败!");
        this.fileList = [];
      }
    },
    smallListNameClick(e) {
      console.log(e);
      this.orderForm.name = e.name;
    },
    //  申购总重量/体积/数量=计算总重量/体积/数量
    changeA() {
      if (this.orderForm.size == "") {
        this.orderForm.total = this.orderForm.singleSize;
      } else {
        this.orderForm.total =
          parseInt(this.orderForm.singleSize) *
            parseInt(this.orderForm.size) *
            parseInt(this.orderForm.bigSize) || "";
      }
      if(this.orderForm.price != ""){
        this.orderForm.totalPrice =  parseInt(this.orderForm.singleSize) * parseInt(this.orderForm.price) || ""
      }
    },
    //申购总重量/体积/数量 = 小包装数量 * 计算总重量/体积/数量
    changeB() {
      if (this.orderForm.bigSize == "") {
        this.orderForm.total =
          parseInt(this.orderForm.singleSize) * parseInt(this.orderForm.size) ||
          "";
      } else {
        this.orderForm.total =
          parseInt(this.orderForm.singleSize) *
            parseInt(this.orderForm.size) *
            parseInt(this.orderForm.bigSize) || "";
      }
      if(this.orderForm.price != ""){
        this.orderForm.totalPrice =  parseInt(this.orderForm.price) * parseInt(this.orderForm.size) || ""
      }
    },
    //申购总重量/体积/数量 = 大包装数量 * 小包装数量 * 计算总重量/体积/数量
    changeC() {
      if (this.orderForm.total != "") {
        this.orderForm.total =
          parseInt(this.orderForm.bigSize) * parseInt(this.orderForm.total) ||
          "";
      } else {
        this.orderForm.total =
          parseInt(this.orderForm.bigSize) *
          parseInt(this.orderForm.singleSize) *
          parseInt(this.orderForm.size)||"";
      }
    },
    changeD() {
      if (this.orderForm.size != "") {
        this.orderForm.totalPrice =
          parseInt(this.orderForm.price) * parseInt(this.orderForm.size) || "";
      } else {
        this.orderForm.totalPrice =
          parseInt(this.orderForm.price) *
            parseInt(this.orderForm.singleSize) || "";
      }
    },
    // 新增/编辑确认
    confirmCreate() {
      if (this.orderForm.id != "") {
        (this.orderForm1.id = this.orderForm.id),
          (this.orderForm1.type = this.orderForm.type),
          (this.orderForm1.batch = this.orderForm.batch),
          (this.orderForm1.bigSize = this.orderForm.bigSize),
          (this.orderForm1.bigUnit = this.orderForm.bigUnit),
          (this.orderForm1.date = this.orderForm.date),
          (this.orderForm1.manufacturer = this.orderForm.manufacturer),
          (this.orderForm1.model = this.orderForm.model),
          (this.orderForm1.name = this.orderForm.name),
          (this.orderForm1.norms = this.orderForm.norms),
          (this.orderForm1.price = this.orderForm.price),
          (this.orderForm1.singleSize = this.orderForm.singleSize),
          (this.orderForm1.singleUnit = this.orderForm.singleUnit),
          (this.orderForm1.size = this.orderForm.size),
          (this.orderForm1.supplier = this.orderForm.supplier),
          (this.orderForm1.supplierPhone = this.orderForm.supplierPhone),
          (this.orderForm1.supplierUser = this.orderForm.supplierUser),
          (this.orderForm1.unit = this.orderForm.unit),
          (this.orderForm1.validity = this.orderForm.validity),
          (this.orderForm1.totalPrice = this.orderForm.totalPrice),
          (this.orderForm1.total = this.orderForm.total);
        this.orderForm1.certificate = this.orderForm.certificate;
        reagentsGlance.updateReagent(this.orderForm1).then(res => {
          console.log(11);
          if (res.code === 200) {
            console.log(res);
            this.$notify({
              title: "成功",
              message: res.message,
              type: "success"
            });
            this.handleSearch();
            this.orderDialogVisible = false;
          }
        });
      } else {
        reagentsGlance.addReaGent(this.orderForm).then(res => {
          console.log(22);
          if (res.code === 200) {
            console.log(res);
            this.$notify({
              title: "成功",
              message: res.message,
              type: "success"
            });
            this.handleSearch();
            this.orderDialogVisible = false;
          } else {
            this.$notify({
              title: "失败",
              message: res.message,
              type: "error"
            });
          }
        });
      }
    },
    //单品标签打印
    handleSingle(row) {
      this.orderDialogSingle = true;
      reagentsGlance.detail({ id: row.id }).then(res => {
        console.log(res);
        this.orderSingle = res.result;
      });
    },
    currentChecked(nodeObj, SelectedObj) {
      let arr = [],
        arr1 = [];
      arr = SelectedObj.checkedKeys.filter(item => item !== undefined);
      // console.log(arr);
      this.installForm.ids = arr;

      for (var item of SelectedObj.checkedNodes) {
        // console.log(item.surplus);
        arr1.push(item.surplus);
        console.log(arr1);
        this.installForm.amount = arr1[0];
      }
    },

    //批量报废
    InstrumentData() {
      if (this.multiplese && this.multiplese.length > 0) {
        this.claim.ids = this.Selection;
        this.purchaseV();
        this.purchaseVisible = true;
      } else {
        this.$message.info("最少选择一条记录信息");
      }
    },

    //报废
    Instrument(row) {
      console.log(row);
      this.claim.ids = row.id.split(",");
      this.purchaseV();
      this.purchaseVisible = true;
    },

    purchaseV() {
      //人
      List.userList().then(res => {
        this.usernameOptions = res.result;
      });
      getUser(this.$store.getters.userInfo.userId).then(response => {
        this.claim.user = response.result.user.empName;
        this.claim.userId = response.result.user.userId;
        this.claim.charge = response.result.user.empName;
        this.claim.chargeId = response.result.user.userId;
      });
    },
    //选择处理人
    handleCheckedCitiesUser(val) {
      console.log(val);
      var arr = [];
      var arrid = [];
      for (var item of val) {
        arr.push(item.empName);
        arrid.push(item.userId);
        this.claim.user = arr.join(", ");
        this.claim.userId = arrid.join(",");
      }
    },
    //选择负责人
    handleChecked(val) {
      console.log(val);
      var arr = [];
      var arrid = [];
      for (var item of val) {
        arr.push(item.empName);
        arrid.push(item.userId);
        this.claim.charge = arr.join(",");
        this.claim.chargeId = arrid.join(",");
      }
    },

    //选择陪同人
    handleAccompanyId(val) {
      console.log(val);
      var arrid = [];
      for (var item of val) {
        arrid.push(item.userId);
        this.orderForm.accompanyId = arrid.join(",");
      }
    },
    //选择保管人
    handleCustodianId(val) {
      console.log(val);
      this.orderForm.custodianId = val.userId;
      console.log(this.orderForm.custodianId);
    },

    // 上传成功
    imgSuccess(res, file, fileList) {
      console.log(file);
      this.fileList = fileList;
      let url = file.response.result;
      let urlStr = url.lastIndexOf("/");
      let fileName = url.substr(urlStr + 1);
      // console.log(fileName);
      this.img.push(fileName);
      //这里我是用一个fileList数组存取，当保存的时候进行图片路径处理
      this.$message({
        type: "success",
        message: "上传成功!"
      });
    },
    // 上传失败
    imgError(res) {
      this.$message({
        type: "error",
        message: "附件上传失败"
      });
    },
    handleExceed(files, fileList) {
      // console.log(files);
      this.$message.warning(
        `当前限制选择 3 张图片，以选 ${
          files.length
        } 张图片，共选择了 ${files.length + fileList.length} 张图片`
      );
    },

    // 上传按钮 限制图片大小和类型
    handleChangeUpload(file, fileList) {
      const isLt2M = file.size / 1024 / 1024 < 2;
      if (!isLt2M) {
        this.$message.error("上传图片大小不能超过 2MB!");
        return false;
      }
    },
    // 附件上传图片预览事件，这个就是将路径直接放进一个弹窗显示出来就可以了

    handlePictureCardPreview(file) {
      console.log(file);
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },

    //报废确认
    confirmType() {
      this.claim.img = this.img.join(",");
      reagentsGlance.scrap(this.claim).then(res => {
        if (res.code === 200) {
          console.log(res);
          this.$notify({
            title: "成功",
            message: res.message,
            type: "success"
          });
          this.handleSearch();
          this.purchaseVisible = false;
        } else {
          this.$notify({
            title: "失败",
            message: res.message,
            type: "error"
          });
        }
      });
    },

     //批量降级弹框
    earlyData() {
      if (this.multiplese && this.multiplese.length > 0) {
        this.id = this.Selection.join(",");
        this.purchase = true;
      } else {
        this.$message.info("最少选择一条记录信息");
      }
    },

    //降级弹框
    earlyWarning(row) {
      console.log(row);
      this.id = row.id;
      this.purchase = true;
    },

    //降级确认
    earlyWarningData() {
      reagentsGlance.demote({ id: this.id }).then(res => {
        if (res.code === 200) {
          console.log(res);
          this.$notify({
            title: "成功",
            message: res.message,
            type: "success"
          });
          this.handleSearch();
          this.purchase = false;
        } else {
          this.$notify({
            title: "失败",
            message: res.message,
            type: "error"
          });
        }
      });
    },
    /** 复制按钮操作 */
    handleCopy(row) {
      console.log(row.id);
      this.$confirm("确定复制?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          reagentsGlance.copy({ id: row.id }).then(res => {
            if (res.code === 200) {
              this.$notify({
                title: "成功",
                message: res.message,
                type: "success"
              });
              this.handleSearch();
            } else {
              this.$notify({
                title: "失败",
                message: res.message,
                type: "error"
              });
            }
          });
        })
        .catch(() => {});
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      this.$confirm('是否确认删除名称为"' + row.name + '"的数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          reagentsGlance.deleteById({ id: row.id }).then(res => {
            if (res.code === 200) {
              this.$notify({
                title: "成功",
                message: res.message,
                type: "success"
              });
              this.handleSearch();
              this.orderDialogVisible = false;
            } else {
              this.$notify({
                title: "失败",
                message: res.message,
                type: "error"
              });
            }
          });
        })
        .catch(() => {});
    }
  }
};
</script>

<style lang="scss" scoped>
/deep/ .el-upload--picture-card {
  background-color: #fbfdff;
  border: 0px dashed #c0ccda;
  border-radius: 12px;
  box-sizing: border-box;
  width: 30px;
  height: 30px;
  cursor: pointer;
  line-height: 40px;
  vertical-align: top;
}
/deep/ .el-upload-list {
  display: flex !important;
  margin: 0px !important;
  width: 100% !important;
  li {
    width: 120px !important;
    height: 80px !important;
    margin: 0 !important;
  }
}

.search_div {
  > div {
    &:nth-child(1) {
      margin-right: 10px;
    }
    display: inline-block;
  }
}

.search_input {
  width: 200px;
  margin-bottom: 5px;
}
.search-right {
  text-align: right;
  padding-right: 25px;
}
.item {
  font-size: 16px;
}
::v-deep .el-card .el-card__header {
  padding: 5px 20px;
  background: #f3f2f2;
}
.block-flex {
  position: relative;
  display: flex;
  & > div {
    border: 1px solid #b7b7b7;
    width: 100px;
    margin: 0;
    line-height: 30px;
    text-align: center;
  }
  & > div:first-child {
    background: #b7b7b7;
  }
}
.card-left {
  width: 100%;
  min-height: 200px;
  max-height: 450px;
}
.card-right {
  width: 100%;
  min-height: 200px;
  max-height: 450px;
}
.el-card {
  overflow: auto;
}
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-icon-arrow-down {
  font-size: 14px;
}
// /deep/.main-body .el-table__header-wrapper  .el-checkbox{
//   display:none
// }
.agreement_picture {
  min-height: calc(100%);
  .pdf {
    height: calc(100%);
  }
}

/deep/ .el-input.is-disabled .el-input__inner {
  color: unset;
}

/deep/.i-input .el-input__inner {
  text-align: center;
}
/deep/.right-input .el-input__inner {
  text-align: right;
}

.el-header {
  line-height: 45px;
  height: 45px;
}
.el-footer {
  text-align: right;
  line-height: 45px;
  height: 45px;

  .pagination-container {
    padding: 0;
    margin-top: 10px;
    margin-bottom: 45px;
  }
}
.el-main {
  overflow-y: auto;
}
.el-container {
  max-height: 450px;
}

.text {
  font-size: 14px;
}
.dialog-item {
  padding-left: 3px;
  line-height: 30px;
  cursor: pointer;
}
.dialog-item:hover {
  background: #e8f4ff;
  border-radius: 3px;
}

table {
  background-color: transparent;
}

caption {
  padding-top: 8px;
  padding-bottom: 8px;
  color: #777;
  text-align: left;
}

th {
  text-align: left;
}

.table {
  width: 100%;
  max-width: 100%;
  margin-bottom: 20px;
}

.table > tbody > tr > td,
.table > tbody > tr > th,
.table > tfoot > tr > td,
.table > tfoot > tr > th,
.table > thead > tr > td,
.table > thead > tr > th {
  padding: 8px;
  line-height: 1.42857143;
  vertical-align: middle;
  border-top: 1px solid #ddd;
}

.table > thead > tr > th {
  vertical-align: bottom;
  border-bottom: 2px solid #ddd;
}

.table > caption + thead > tr:first-child > td,
.table > caption + thead > tr:first-child > th,
.table > colgroup + thead > tr:first-child > td,
.table > colgroup + thead > tr:first-child > th,
.table > thead:first-child > tr:first-child > td,
.table > thead:first-child > tr:first-child > th {
  border-left: 1px solid #f1f2f4;
}

.table > tbody + tbody {
  border-top: 2px solid #ddd;
}

.table .table {
  background-color: #fff;
}

.table-condensed > tbody > tr > td,
.table-condensed > tbody > tr > th,
.table-condensed > tfoot > tr > td,
.table-condensed > tfoot > tr > th,
.table-condensed > thead > tr > td,
.table-condensed > thead > tr > th {
  padding: 5px;
}

.table-bordered {
  border: 1px solid #ddd;
}

.table-bordered > tbody > tr > td,
.table-bordered > tbody > tr > th,
.table-bordered > tfoot > tr > td,
.table-bordered > tfoot > tr > th,
.table-bordered > thead > tr > td,
.table-bordered > thead > tr > th {
  border: 1px solid #ddd;
}

.table-bordered > thead > tr > td,
.table-bordered > thead > tr > th {
  border-bottom-width: 2px;
}

.table-striped > tbody > tr:nth-of-type(odd) {
  background-color: #f9f9f9;
}

.table-hover > tbody > tr:hover {
  background-color: #f5f5f5;
}

table col[class*="col-"] {
  position: static;
  display: table-column;
  float: none;
}

table td[class*="col-"],
table th[class*="col-"] {
  position: static;
  display: table-cell;
  float: none;
}

.table > tbody > tr.active > td,
.table > tbody > tr.active > th,
.table > tbody > tr > td.active,
.table > tbody > tr > th.active,
.table > tfoot > tr.active > td,
.table > tfoot > tr.active > th,
.table > tfoot > tr > td.active,
.table > tfoot > tr > th.active,
.table > thead > tr.active > td,
.table > thead > tr.active > th,
.table > thead > tr > td.active,
.table > thead > tr > th.active {
  background-color: #f5f5f5;
}

.table-hover > tbody > tr.active:hover > td,
.table-hover > tbody > tr.active:hover > th,
.table-hover > tbody > tr:hover > .active,
.table-hover > tbody > tr > td.active:hover,
.table-hover > tbody > tr > th.active:hover {
  background-color: #e8e8e8;
}

.table > tbody > tr.success > td,
.table > tbody > tr.success > th,
.table > tbody > tr > td.success,
.table > tbody > tr > th.success,
.table > tfoot > tr.success > td,
.table > tfoot > tr.success > th,
.table > tfoot > tr > td.success,
.table > tfoot > tr > th.success,
.table > thead > tr.success > td,
.table > thead > tr.success > th,
.table > thead > tr > td.success,
.table > thead > tr > th.success {
  background-color: #dff0d8;
}

.table-hover > tbody > tr.success:hover > td,
.table-hover > tbody > tr.success:hover > th,
.table-hover > tbody > tr:hover > .success,
.table-hover > tbody > tr > td.success:hover,
.table-hover > tbody > tr > th.success:hover {
  background-color: #d0e9c6;
}

.table > tbody > tr.info > td,
.table > tbody > tr.info > th,
.table > tbody > tr > td.info,
.table > tbody > tr > th.info,
.table > tfoot > tr.info > td,
.table > tfoot > tr.info > th,
.table > tfoot > tr > td.info,
.table > tfoot > tr > th.info,
.table > thead > tr.info > td,
.table > thead > tr.info > th,
.table > thead > tr > td.info,
.table > thead > tr > th.info {
  background-color: #d9edf7;
}

.table-hover > tbody > tr.info:hover > td,
.table-hover > tbody > tr.info:hover > th,
.table-hover > tbody > tr:hover > .info,
.table-hover > tbody > tr > td.info:hover,
.table-hover > tbody > tr > th.info:hover {
  background-color: #c4e3f3;
}

.table > tbody > tr.warning > td,
.table > tbody > tr.warning > th,
.table > tbody > tr > td.warning,
.table > tbody > tr > th.warning,
.table > tfoot > tr.warning > td,
.table > tfoot > tr.warning > th,
.table > tfoot > tr > td.warning,
.table > tfoot > tr > th.warning,
.table > thead > tr.warning > td,
.table > thead > tr.warning > th,
.table > thead > tr > td.warning,
.table > thead > tr > th.warning {
  background-color: #fcf8e3;
}

.table-hover > tbody > tr.warning:hover > td,
.table-hover > tbody > tr.warning:hover > th,
.table-hover > tbody > tr:hover > .warning,
.table-hover > tbody > tr > td.warning:hover,
.table-hover > tbody > tr > th.warning:hover {
  background-color: #faf2cc;
}

.table > tbody > tr.danger > td,
.table > tbody > tr.danger > th,
.table > tbody > tr > td.danger,
.table > tbody > tr > th.danger,
.table > tfoot > tr.danger > td,
.table > tfoot > tr.danger > th,
.table > tfoot > tr > td.danger,
.table > tfoot > tr > th.danger,
.table > thead > tr.danger > td,
.table > thead > tr.danger > th,
.table > thead > tr > td.danger,
.table > thead > tr > th.danger {
  background-color: #f2dede;
}

.table-hover > tbody > tr.danger:hover > td,
.table-hover > tbody > tr.danger:hover > th,
.table-hover > tbody > tr:hover > .danger,
.table-hover > tbody > tr > td.danger:hover,
.table-hover > tbody > tr > th.danger:hover {
  background-color: #ebcccc;
}

.table-responsive {
  min-height: 3.01%;
  overflow-x: auto;
}

.table-bordered,
.table-bordered > tbody > tr > td,
.table-bordered > tbody > tr > th,
.table-bordered > tfoot > tr > td,
.table-bordered > tfoot > tr > th,
.table-bordered > thead > tr > td,
.table-bordered > thead > tr > th {
  border: 1px solid #e9ecef;
  text-align: center;
  line-height: 14px;
}

.table-bordered,
td,
th {
  border-radius: 0 !important;
}

.table-bordered > tbody > tr:last-child > td {
  border-bottom: 1px solid #e9ecef;
}

.bootstrap-table .fixed-table-container .fixed-table-header {
  overflow: hidden;
  background: rgba(0, 0, 0, 0.05);
}

.fixed-table-header .table > thead > tr {
  background: none !important;
}

.table > thead > tr {
  color: #636363;
  font-weight: 400;
  background: rgba(0, 0, 0, 0.05);
  /*   background: repeat-x #fafafa;
  background-image: -webkit-linear-gradient(top,#F8F8F8 0,#fafafa 100%);
  background-image: -o-linear-gradient(top,#F8F8F8 0,#fafafa 100%);
  background-image: linear-gradient(to bottom,#F8F8F8 0,#fafafa 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff8f8f8', endColorstr='#ffececec', GradientType=0); */
}

.table > thead > tr > th {
  border-color: #e9ecef;
  font-weight: 700;
  border-right-color: transparent;
}

.table > thead > tr > th .ace-icon:first-child {
  margin-right: 2px;
}

.table > thead > tr > th:first-child {
  border-left-color: #f1f1f1;
}

.table > thead > tr > th:last-child {
  border-right-color: #f1f1f1;
}

.table.table-bordered > thead > tr > th {
  vertical-align: middle;
}

td.center,
th.center {
  text-align: center;
}

td .lbl,
th .lbl {
  margin-bottom: 0;
}

td .lbl:only-child,
th .lbl:only-child {
  vertical-align: top;
}

.table-header {
  background-color: #307ecc;
  color: #fff;
  font-size: 14px;
  line-height: 38px;
  padding-left: 12px;
  margin-bottom: 1px;
}

.table-header .close {
  margin-right: 8px;
  margin-top: 0;
  opacity: 0.45;
  filter: alpha(opacity=45);
}

.table-header .close:hover {
  opacity: 0.75;
  filter: alpha(opacity=75);
}

th.detail-col {
  width: 48px;
  text-align: center;
}

tr.detail-row {
  display: none;
}

tr.detail-row.open {
  display: block;
  display: table-row;
}

tr.detail-row > td {
  background-color: #f1f6f8;
  border-top: 3px solid #d1e1ea !important;
}

.table-detail {
  background-color: #fff;
  border: 1px solid #dcebf7;
  width: 100%;
  padding: 12px;
}

.table-detail td > .profile-user-info {
  width: 100%;
}
.clearfix {
  line-height: 40px;
  display: flex;
}
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-icon-arrow-down {
  font-size: 12px;
}
.install-title {
  display: flex;
  align-items: center;
  line-height: 30px;
  padding-left: 20px;
  color: #fff;
  background-color: #d7dae2;
  justify-content: flex-start;
  margin-bottom: 10px;
}
.delete {
  width: 10px;
  height: 10px;
  position: relative;
  top: -10px;
  cursor: pointer;
}
.user-info-head {
  position: relative;
  display: inline-block;
  height: 120px;
}

::v-deep.avatar-upload-preview {
  width: 400px;
  border-radius: 0%;
  height: 400px;
  > img {
    transform: translateX(0);
  }
}
.user-info-head:hover:after {
  content: "+";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  color: #eee;
  background: rgba(0, 0, 0, 0.5);
  font-size: 24px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  cursor: pointer;
  line-height: 110px;
  border-radius: 50%;
}

/deep/.upload-dragger {
  background-color: #fff;
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  text-align: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.cropper-wrapper {
  //height: calc(100vh - 50px);
  .pre-box {
    button {
      width: 100px;
      margin-top: 15px;
    }
  }
}

/deep/.el-dialog {
  position: relative;
  margin: 0 auto 50px;
  background: #fff;
  border-radius: 2px;
  box-sizing: border-box;
  width: 80%;
}

.crop-dialog {
  .cropper-content {
    padding: 0 40px;

    .cropper {
      width: 900px;
      height: 900px;
    }
  }

  .action-box {
    padding: 25px 40px 0 40px;
    display: flex;
    justify-content: center;

    button {
      width: 80px;
      margin-right: 15px;
    }
  }

  .dialog-footer {
    button {
      width: 100px;
    }
  }
}
.green {
  color: green;
}
.red {
  color: orangered;
}
</style>
